import RPi.GPIO as GPIO

class Laser:
    ON=0
    OFF=1
   
    def __init__(self,spin):
        self.s=spin
        GPIO.setup(self.s, GPIO.OUT, initial=GPIO.LOW)
        self.DICT_CMD_ACTION = {Laser.ON: self.laser_on,
                                Laser.OFF: self.laser_off,
                                }        
   
    def laser_on(self):
        GPIO.output(self.s, GPIO.HIGH)
   
    def laser_off(self):
        GPIO.output(self.s, GPIO.LOW)
   
    def action(self, cmd_to_laser):
        self.DICT_CMD_ACTION[cmd_to_laser]()

      
if __name__ == '__main__': 
    import time
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    GPIO.cleanup()
    laser = Laser(26)  # singal
    laser.action(Laser.ON)
    time.sleep(5)
    laser.action(Laser.OFF)
    
